/**
 * author:Administrator
 * date:2016/2/24
 * desc:TODO
 */

'use strict';

let seq = 1;
let list = {};
let ROOT_PID = 0;

class CategoryRepoImpl {

  static * genId() {
    return 'cate_' + (seq++);
  }

  static * find(id) {
    return list[id];
  }

  static * store(cate) {
    if (!cate.id) cate.id = yield CategoryRepoImpl.genId();
    if (typeof cate.pid == 'undefined') cate.pid = ROOT_PID;

    list[cate.id] = cate;
  }
}
module.exports = CategoryRepoImpl;